<template>
  <div class="special-detail-page">
    <div class="container">
      <!-- 面包屑 -->
      <XtxBread>
        <XtxBreadItem to="/">首页</XtxBreadItem>
        <transition name="fade-right" mode="out-in">
          <XtxBreadItem>专题列表</XtxBreadItem>
        </transition>
        <transition name="fade-right" mode="out-in">
          <XtxBreadItem>专题详情</XtxBreadItem>
        </transition>
      </XtxBread>
      <!-- 品牌信息 -->
      <div class="brand-info">
        <div class="image">
          <img :src="specialInfo.cover" alt="">
        </div>
        <div class="info">
          <p class="name">{{specialInfo.title}}</p>
          <p class="desc">{{specialInfo.summary}}</p>
          <!-- <p class="icon">
            <i class="iconfont icon-dingwei"></i>
            <span>{{specialInfo.productionPlace}}</span>
            <i class="iconfont icon-xin2 red"></i>
            <span>{{specialInfo.collectNum}}</span>
          </p> -->
          <!-- <p class="text">
            <span>品牌故事：</span>
            <span>{{specialInfo.brandStory}}</span>
          </p> -->
        </div>
         <xtx-button type="primary" v-if="specialInfo.isCollect === false" @click="CollectSpecial" v-show="!isCollect">收藏专题</xtx-button>
         <xtx-button type="gray" v-else @click="CollectCancel">取消收藏</xtx-button>
      </div>
    </div>
  </div>
</template>

<script>
import { findSpecialDetail, collectSpecial } from '@/api/special'
import { useRoute } from 'vue-router'
import { onMounted, ref } from 'vue'
import Message from '@/components/library/message'
export default {
  name: 'SpecialDetail',
  setup () {
    const route = useRoute()
    const specialInfo = ref([])
    onMounted(() => {
      getSpecialDetail()
    })
    const getSpecialDetail = () => {
      findSpecialDetail(route.params.id).then(data => {
        specialInfo.value = data.result
      })
    }
    // 添加专题收藏
    const isCollect = ref(false)
    const CollectSpecial = () => {
      isCollect.value = true
      collectSpecial(route.params.id, isCollect.value).then(data => {
        getSpecialDetail()
        Message({ type: 'success', text: '专题收藏成功' })
      })
    }
    const CollectCancel = () => {
      isCollect.value = false
      collectSpecial(route.params.id, isCollect.value).then(data => {
        getSpecialDetail()
        Message({ type: 'warn', text: '取消收藏成功' })
      })
    }
    return { specialInfo, isCollect, CollectSpecial, CollectCancel }
  }
}
</script>

<style lang="less" scoped>
.special-detail-page {
  height: 100%;
  background: #fff;
  min-height: 600px;
  .brand-info {
  display: flex;
  background: #fff;
  height: 300px;
  img {
    width: 100%;
    height: 100%;
  }
  .image {
    width: 300px;
    height: 300px;
  }
  .info {
    flex: 1;
    padding: 0 30px;
    position: relative;
    .name {
      font-size: 20px;
      padding-right: 160px;
      line-height: 50px;
    }
  }
  .like {
      width: 150px;
      height: 46px;
      background: #27ba9b;
      border-radius: 4px;
      color: #fff;
      text-align: center;
      line-height: 46px;
      margin: 0 30px;
      right: 0;
      cursor: pointer;
    }
}
}
</style>
